package com.longxi.tianjintianbao.ui.adapter.multitype.energy_read;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.listener.SelectRepairDetailListener;
import com.longxi.tianjintianbao.model.energy.EnergyRead;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by cxw on 2018/2/20.
 */
public class EnergyReadListViewBinder extends ItemViewBinder<EnergyRead, EnergyReadListViewBinder.ViewHolder> {

    SelectRepairDetailListener listener;

    public EnergyReadListViewBinder(SelectRepairDetailListener listener) {
        this.listener = listener;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_energy_read_list, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull EnergyRead energyRead) {
        holder.mLlWaterMeter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onSuccess("");
            }
        });
        holder.mLlWattHourMeter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onSuccess("");
            }
        });
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        LinearLayout mLlBtn;
        LinearLayout mLlWaterMeter;
        LinearLayout mLlWattHourMeter;
        ViewHolder(View itemView) {
            super(itemView);
            mLlBtn = itemView.findViewById(R.id.llBtn);
            mLlWaterMeter = itemView.findViewById(R.id.llWaterMeter);
            mLlWattHourMeter = itemView.findViewById(R.id.llWattHourMeter);
        }
    }
}
